package com.example.p6;

import java.io.File;
import java.io.IOException;

public class RunoobTest {
    public static void main(String[] args)throws IOException {
        File oldName=new File("./runoob-test.txt");
        File newName=new File("./runoob-test-2.txt");
        if(newName.exists()){
            throw new java.io.IOException("file exists");
        }
        if(oldName.renameTo(newName)){
            System.out.println("文件重命名成功");
        }else{
            System.out.println("Error");
        }
    }
}
